﻿#region Copyright and License
/*==============================================================================
 *  Copyright (c) cndotnet.org Corporation.  All rights reserved.
 * ===============================================================================
 * This code and information is provided "as is" without warranty of any kind,
 * either expressed or implied, including but not limited to the implied warranties
 * of merchantability and fitness for a particular purpose.
 * ===============================================================================
 * Licensed under the GNU General Public License (GPL) v2
 * http://www.cndotnet.org/ezsocio
 * ==============================================================================*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DusonFramework.DependenceInjection
{
    /// <summary>
    /// The interface of container context
    /// </summary>
    public interface IContainerContext
    {
        /// <summary>
        /// Gets the name.
        /// </summary>
        /// <value>The name.</value>
        string Name { get; }

        /// <summary>
        /// Occurs before container initialized.
        /// </summary>
        event EventHandler<ContainerEventArgs> BeforeInitialized;

        /// <summary>
        /// Occures after container initialized
        /// </summary>
        event EventHandler<ContainerEventArgs> AfterInitialized;

        /// <summary>
        /// Occures before container teardown
        /// </summary>
        event EventHandler<ContainerEventArgs> BeforeTearDown;

        /// <summary>
        /// Occures after container teardown
        /// </summary>
        event EventHandler<ContainerEventArgs> AfterTearDown;

        /// <summary>
        /// Occures when container resolve failed
        /// </summary>
        event EventHandler<ContainerFailedEventArgs> ResolveFailed;

        /// <summary>
        /// Initializes container.
        /// </summary>
        void Initialize();

        /// <summary>
        /// Resolves special instance.
        /// </summary>
        /// <typeparam name="T">Parameter type</typeparam>
        /// <returns></returns>
        T Resolve<T>();

        /// <summary>
        /// Tears down.
        /// </summary>
        void TearDown();
    }
}
